bpf: Simplify alu_limit masking for pointer arithmetic
authorPiotr Krysiuk <piotras@gmail.com>
Tue, 16 Mar 2021 07:26:25 +0000 (08:26 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 19 Mar 2021 18:20:52 +0000 (18:20 +0000)
commitc8129f85dba04e7b6bcff909190fcd8c7e74691f
treecbf7ef479d7680ff7b4e502d18f62004db859526
parent4c4129a2515b4250e647447cf4b6d7ace9321cac
bpf: Simplify alu_limit masking for pointer arithmetic

Origin: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit?id=b5871dca250cd391885218b99cc015aca1a51aea

Instead of having the mov32 with aux->alu_limit - 1 immediate, move this
operation to retrieve_ptr_limit() instead to simplify the logic and to
allow for subsequent sanity boundary checks inside retrieve_ptr_limit().
This avoids in future that at the time of the verifier masking rewrite
we'd run into an underflow which would not sign extend due to the nature
of mov32 instruction.

Signed-off-by: Piotr Krysiuk <piotras@gmail.com>
Co-developed-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name bpf-Simplify-alu_limit-masking-for-pointer-arithmeti.patch
kernel/bpf/verifier.c